﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Agresso.Interface.Layer.SQL
{
    public class ud_voyageimpSQL
    {
        public static string Insert()
        {
            return @"
            INSERT INTO ud_voyageimp
           ([client]
           ,[attribute_id]
           ,[dim_value]
           ,[description]
           ,[rel_value]
           ,[voy_cpdate]
           ,[voy_actual_voy_start]
           ,[voy_actual_voy_end]
           ,[voy_total_actual_duration]
           ,[voy_offhire_duration]
           ,[voy_cargo_type]
           ,[voy_cargo_quantity]
           ,[voy_fixture_number]
           ,[voy_freight_rate_per_day]
           ,[voy_tc_rate_per_day]
           ,[voy_type_of_vc]
           ,[voy_head_fixture_ref]
           ,[processed_status]
           ,[processed_date]
            ,[voy_actual_voy_start_time]
            ,[voy_actual_voy_end_time]
            ,[voy_lumpsum_freight]
            ,[voy_cargo_quantity1]
            ,[voy_charterer]
            )
     VALUES
           (@client
           ,@attribute_id
           ,@dim_value
           ,@description
           ,@rel_value
           ,@voy_cpdate
           ,@voy_actual_voy_start
           ,@voy_actual_voy_end
           ,@voy_total_actual_duration
           ,@voy_offhire_duration
           ,@voy_cargo_type
           ,@voy_cargo_quantity
           ,@voy_fixture_number
           ,@voy_freight_rate_per_day
           ,@voy_tc_rate_per_day
           ,@voy_type_of_vc
           ,@voy_head_fixture_ref
           ,@processed_status
           ,@processed_date
            ,@voy_actual_voy_start_time
            ,@voy_actual_voy_end_time
            ,@voy_lumpsum_freight
            ,@voy_cargo_quantity1
            ,@voy_charterer
            )
            ";
        }

        public static string InsertIntoMiddleLayer()
        {
            return @"
            INSERT INTO i_ud_voyageimp
           (
            [recid]
           ,[client]
           ,[attribute_id]
           ,[dim_value]
           ,[description]
           ,[rel_value]
           ,[voy_cpdate]
           ,[voy_actual_voy_start]
           ,[voy_actual_voy_end]
           ,[voy_total_actual_duration]
           ,[voy_offhire_duration]
           ,[voy_cargo_type]
           ,[voy_cargo_quantity]
           ,[voy_fixture_number]
           ,[voy_freight_rate_per_day]
           ,[voy_tc_rate_per_day]
           ,[voy_type_of_vc]
           ,[voy_head_fixture_ref]
           ,[processed_status]
           ,[processed_date]
            ,[voy_actual_voy_start_time]
            ,[voy_actual_voy_end_time]
            ,[voy_lumpsum_freight]
            ,[voy_cargo_quantity1]
            ,[voy_charterer]
            ,[insert_date]
            )
     VALUES
           (
            @recid
           ,@client
           ,@attribute_id
           ,@dim_value
           ,@description
           ,@rel_value
           ,@voy_cpdate
           ,@voy_actual_voy_start
           ,@voy_actual_voy_end
           ,@voy_total_actual_duration
           ,@voy_offhire_duration
           ,@voy_cargo_type
           ,@voy_cargo_quantity
           ,@voy_fixture_number
           ,@voy_freight_rate_per_day
           ,@voy_tc_rate_per_day
           ,@voy_type_of_vc
           ,@voy_head_fixture_ref
           ,@processed_status
           ,@processed_date
            ,@voy_actual_voy_start_time
            ,@voy_actual_voy_end_time
            ,@voy_lumpsum_freight
            ,@voy_cargo_quantity1
            ,@voy_charterer
            ,@insert_date
            )
            ";
        }

        public static string GetMaxrecidud_voyageimpSQL()
        {
            return @"select max(recid) from ud_voyageimp";
        }

        //public static string IsRegisteredVoyage()
        //{
        //    return "select count(*) from ud_voyageimp where dim_value=@dim_value";
        //}

        public static string IsRegisteredVoyage()
        {
            return "select count(*) from agldimvalue where attribute_id = 'P8A' and dim_value=@dim_value";
        }

        public static string GetAFXVOYAGEByDimValue()
        {
            return "select * from afxvoyage where attribute_id = 'P8A' and dim_value=@dim_value";
        }

        public static string Find()
        {
            return @"
            select * from ud_voyageimp where
            [client] = @client
            AND [attribute_id]= @attribute_id
            AND [dim_value]= @dim_value
            AND [description]= @description
            AND [rel_value]= @rel_value
            AND [voy_cpdate]= @voy_cpdate
            AND [voy_actual_voy_start]= @voy_actual_voy_start
            AND [voy_actual_voy_end]= @voy_actual_voy_end
            AND [voy_total_actual_duration]= @voy_total_actual_duration
            AND [voy_offhire_duration]= @voy_offhire_duration
            AND [voy_cargo_type]= @voy_cargo_type
            AND [voy_cargo_quantity]= @voy_cargo_quantity
            AND [voy_fixture_number]= @voy_fixture_number
            AND [voy_freight_rate_per_day]= @voy_freight_rate_per_day
            AND [voy_tc_rate_per_day]= @voy_tc_rate_per_day
            AND [voy_type_of_vc]= @voy_type_of_vc
            AND [voy_head_fixture_ref]= @voy_head_fixture_ref
            AND [processed_status]= @processed_status
            AND [processed_date]= @processed_date
             AND [voy_actual_voy_start_time]= @voy_actual_voy_start_time
             AND [voy_actual_voy_end_time]= @voy_actual_voy_end_time
             AND [voy_lumpsum_freight]= @voy_lumpsum_freight
            ";
        }

        public static string Update()
        {
            return @"
            update ud_voyageimp set 
            [client] = @client
            , [attribute_id]= @attribute_id
            , [dim_value]= @dim_value
            , [description]= @description
            , [rel_value]= @rel_value
            , [voy_cpdate]= @voy_cpdate
            , [voy_actual_voy_start]= @voy_actual_voy_start
            , [voy_actual_voy_end]= @voy_actual_voy_end
            , [voy_total_actual_duration]= @voy_total_actual_duration
            , [voy_offhire_duration]= @voy_offhire_duration
            , [voy_cargo_type]= @voy_cargo_type
            , [voy_cargo_quantity]= @voy_cargo_quantity
            , [voy_fixture_number]= @voy_fixture_number
            , [voy_freight_rate_per_day]= @voy_freight_rate_per_day
            , [voy_tc_rate_per_day]= @voy_tc_rate_per_day
            , [voy_type_of_vc]= @voy_type_of_vc
            , [voy_head_fixture_ref]= @voy_head_fixture_ref
            , [processed_status]= @processed_status
            , [processed_date]= @processed_date
             , [voy_actual_voy_start_time= @voy_actual_voy_start_time
             , [voy_actual_voy_end_time]= @voy_actual_voy_end_time
             , [voy_lumpsum_freight]= @voy_lumpsum_freight
             where recid=@recid";
        }
    }
}
